package com.wpi.smarttour.helpers;
import android.content.Context;
import android.util.Log;
import android.widget.Toast;

/*
 * Common functions that are used in all actvities
 * Contains Log functions
 * And STATIC vars
 */
public class Utilities
{
   private static final int LOGLEVEL = 5;
   private static final String tag = "SMARTTOUR";
   public static final String IP_ADDRESS = "http://10.100.146.158";

   // private static int TOAST_DURATION = Toast.LENGTH_SHORT;
   // Log messages
   public static void LogInfo(String message)
   {
      if (LOGLEVEL >= 3)
      {
         Log.i(tag, message);
      }
   }

   public static void LogError(String methodName, Exception ex)
   {
      try
      {
         LogError(methodName + ":" + ex.getMessage());
      }
      catch (Exception e)
      {
         /**/
      }
   }

   public static void LogError(String message)
   {
      Log.e(tag, message);
   }

   public static void LogDebug(String message)
   {
      if (LOGLEVEL >= 4)
      {
         Log.d(tag, message);
      }
   }

   public static void LogDebug(String method, String message)
   {
      if (LOGLEVEL >= 4)
      {
         Log.d(tag, method + ": " + message);
      }
   }

   public static void LogWarning(String message)
   {
      if (LOGLEVEL >= 2)
      {
         Log.w(tag, message);
      }
   }

   public static void LogVerbose(String message)
   {
      if (LOGLEVEL >= 5)
      {
         Log.v(tag, message);
      }
   }

   // Toast Messages
   public static void msgUpdatingLocation(Context c)
   {
      String msg = "Updating Location";
      int TOAST_DURATION = Toast.LENGTH_SHORT;
      Toast.makeText(c, msg, TOAST_DURATION).show();
   }

   public static void msgUser(String msg, Context c)
   {
      int TOAST_DURATION = Toast.LENGTH_LONG;
      Toast.makeText(c, msg, TOAST_DURATION).show();
   }

   public static void msgUserShort(String msg, Context c)
   {
      int TOAST_DURATION = Toast.LENGTH_SHORT;
      Toast.makeText(c, msg, TOAST_DURATION).show();
   }
}
